package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	ttwo
*/
public class ttwo {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("ttwo.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"ttwo.out")));
		new ttwo().solve(f, out);
		out.close();
		System.exit(0);
	}

	// North = 0, EAST = 100, SOUTH = 200, WEST = 300
	private int N = 10;
	private boolean[][] m = new boolean[N][N];
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		int farmer=0, cow=0;
		for (int i=0; i<N; i++) {
			String line = f.readLine();
			for (int j=0; j<N; j++) {
				switch(line.charAt(j)) {
				case '*':
					m[i][j] = true;
					break;
				case 'F':
					farmer = i*10 + j;
					break;
				case 'C':
					cow = i*10 + j;
					break;
				}
			}
		}
		
		HashSet<Pair> visited = new HashSet<Pair>();
		Pair p = new Pair(farmer, cow);
		visited.add(p);
		
		for(int step=0; ; step++) {
			if (p.farmer%100 == p.cow%100) {
				out.println(step);
				return;
			}
			
			p = p.move();
			System.out.println(step + ". " + p.farmer + " " + p.cow);
			if (visited.contains(p)) {
				out.println(0);
				return;
			}
			
			visited.add(p);
		}
	}
	
	private class Pair {
		int farmer;
		int cow;
		
		public Pair(int farmer, int cow) {
			this.farmer = farmer;
			this.cow = cow;
		}
		
		public Pair move() {
			return new Pair(next(farmer), next(cow));
		}
		
		public int hashCode() {
			return farmer*400 + cow;
		}
		
		public boolean equals(Object obj) {
			Pair o = (Pair)obj;
			return farmer==o.farmer && cow==o.cow;
		}
		
		private int next(int pos) {
			int direction = pos/100;
			int t = pos%100;
			int x = t/10;
			int y = t%10;
			
			t = forward(x, y, direction);
			if (t < 0) {
				direction = (direction+1)%4;
				return direction*100 + x*10 + y;
			}
			else {
				return t;
			}
		}
		
		private int forward(int x, int y, int direction) {
			int nx = x, ny = y;
			switch (direction) {
			case 0:
				nx--;
				break;
			case 1:
				ny++;
				break;
			case 2:
				nx++;
				break;
			default:
				ny--;	
			}
			
			if (nx<0 || nx>9 || ny<0 || ny>9 || m[nx][ny]) return -1;
			return nx*10 + ny + direction*100;
		}
	}
}
